import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/
export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/menu11/{username}',
    component: Layout,
    redirect: '/example/table',
    name: '系统管理',
    meta: {title: '系统管理', icon: 'menus11'},
    children: [
      {
        path: 'table1',
        name: '菜单管理',
        component: () => import('@/views/table/index'),
        meta: {title: '菜单管理', icon: 'menus'}
      },
      {
        path: '1',
        name: '角色管理',
        // component: () => import('@/views/tree/index'),
        meta: {title: '角色管理', icon: 'role'}
      }, {
        path: '2',
        name: '字典管理',
        // component: () => import('@/views/tree/index'),
        meta: {title: '字典管理', icon: 'Dictionaries'}
      },
      {
        path: '3',
        name: '部门管理',
        component: () => import('@/views/tree/index'),
        meta: {title: '部门管理', icon: 'department'}
      },
      {
        path: '4',
        name: '岗位管理',
        component: () => import('@/views/tree/index'),
        meta: {title: '岗位管理', icon: 'post'}
      },
      {
        path: '5',
        name: '用户管理',
        // component: () => import('@/views/tree/index'),
        meta: {title: '用户管理', icon: 'user'}
      },
      {
        path: '6',
        name: '日志管理',
        component: () => import('@/views/tree/index'),
        meta: {title: '日志管理', icon: 'journal'}
      },
    ]
  },

  {
    path: '/menu22/{username}',
    component: Layout,
    redirect: '/example/table2',
    name: '社区资产',
    meta: {title: '社区资产', icon: 'menu1'},
    children: [
      {
        path: 'table',
        name: '小区信息',
        component: () => import('@/views/table/index'),
        meta: {title: '小区信息', icon: 'community'}
      },
      {
        path: '1',
        name: '楼栋信息',
        component: () => import('@/views/tree/index'),
        meta: {title: '楼栋信息', icon: 'house'}
      }, {
        path: '2',
        name: '单元信息',
        component: () => import('@/views/tree/index'),
        meta: {title: '单元信息', icon: 'unit'}
      },
      {
        path: '3',
        name: '房屋信息',
        component: () => import('@/views/tree/index'),
        meta: {title: '房屋信息', icon: 'building'}
      },

    ]
  },
  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: '小区管理',
    meta: {
      title: '小区管理',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: '业主审核',
        meta: {title: '业主审核'},
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: '',
            meta: {title: ''}
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: {title: 'Menu1-2'},
            children: [
              {
                path: '业主信息',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: '业主信息',
                meta: {title: ''}
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: {title: 'Menu1-2-2'}
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: {title: 'Menu1-3'}
          }
        ]
      },
      {
        path: '业主信息',
        component: () => import('@/views/nested/menu2/index'),
        meta: {title: '业主信息'}
      }
    ]
  },
  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: '11',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: {title: '互动管理', icon: 'form'}
      }
    ]
  },
  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: 'visitor',
        name: 'visitor',
        component: () => import('@/views/management/visitor'),
        meta: {title: '访客管理', icon: 'form'}
      }
    ]
  },
  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: '/management',
        name: 'Form',
        component: () => import('@/views/management/suggest'),
        meta: {title: '投诉建议', icon: 'form'}
      }
    ]
  },
  {
    path: '/form',
    component: Layout,
    children: [
      {
        path: '44',
        name: 'Form',
        component: () => import('@/views/management/repair'),
        meta: {title: '保修管理', icon: 'form'}
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: {title: '更多 信息', icon: 'link'}
      }
    ]
  },

  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
